package com.zzyl.mapper;


import com.github.pagehelper.Page;
import com.zzyl.entity.NursingProject;

import com.zzyl.vo.NursingProjectVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface NursingProjectMapper {

    /**
     * 插入护理项目
     *
     * @param nursingProject 要插入的护理项目对象
     * @return 影响的记录数
     */
    int insertNursingProject(NursingProject nursingProject);

    /**
     * 根据ID删除护理项目
     *
     * @param id 护理项目的ID
     * @return 影响的记录数
     */
    int deleteNursingProjectById(Long id);

    /**
     * 更新护理项目信息
     *
     * @param nursingProject 包含更新信息的护理项目对象
     * @return 影响的记录数
     */
    int updateNursingProject(NursingProject nursingProject);

    /**
     * 根据ID读取护理项目信息
     *
     * @param id 护理项目的ID
     * @return 护理项目的View Object
     */
    NursingProjectVo readNursingProjectById(Long id);


    Page<NursingProjectVo> selectByPage(Integer pageNum, Integer pageSize, String name, Integer status);

    @Select("select count(*) from nursing_project where name = #{name}")
    int countByName(NursingProject nursingProject);


    @Select("select count(*) from nursing_project where id = #{id}")
    int countById(Long id);


    @Update("update nursing_project set status =(1-status) where id = #{id}")
    void alterStatus(Long id, Integer status);

    @Select("select * from nursing_project where status = 1")
    List<NursingProjectVo> selectAll();

    @Select("select status from nursing_project where id = #{id}")
    int getStatus(Long id);

    @Select("select count(*) from nursing_project where order_no = #{number}")
    int countByOrderNo(int number);
}
